package org.test2;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class OpenCV_Test1 {

    public static void main(String[] args) {

        // 将opencv_javaXX.dll 放在下列路径中
        System.out.println(System.getProperty("java.library.path"));

        //加载 opencv_javaXX.dll
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        System.out.println("OpenCV版本：" + Core.VERSION);

        //测试图片地址
        String imgPath = "11.jpeg";
        //读取图片
        Mat img = Imgcodecs.imread(imgPath);
        //生成灰度图
        Mat gray = new Mat();
        Imgproc.cvtColor(img, gray, Imgproc.COLOR_BGR2GRAY);
        //保存图片
        Imgcodecs.imwrite("11.png", gray);
    }

}
